<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/11/17
  Time: 11:01
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">
    <script type="text/javascript" src="js/jquery-1.7.1.js"></script>
    <title>用户列表</title>
    <style>
        body{
            background: url(image/1.jpg) right bottom no-repeat;
            text-align: center;
            margin-top: 20px;
        }
        #table1{
            text-align: center;
            margin: auto;
            width: 80%;
            height: 80%;
            border: 5px solid cadetblue;
            margin-top:20px;
        }
        h3{
            float: right;
        margin-right: 60px;}
        tr>th{
            background:lightgrey;
        }
        p{
            font-size: 24px;
            color: rebeccapurple;
            font-style:normal;
        }
    </style>
    <script type="text/javascript">
        function del(id){
            $.get("<%=basePath%>user/delUser?id=" + id,function(data){
                if("success" == data.result){
                    alert("删除成功");
                    window.location.reload();
                }else{
                    alert("删除失败");
                }
            });
        }
    </script>
</head>

<body>
<h3><a href="<%=basePath%>user/toAddUser">添加用户</a></h3>
<table border="1" id="table1">
    <p>用户信息表</p>
    <tbody>
    <tr border="1px soild blue">
        <th>姓名</th>
        <th>年龄</th>
        <th>性别</th>
        <th>职业</th>
        <th>学校</th>
        <th>爱好</th>
        <th>操作</th>
    </tr>
        <c:forEach items="${userList}" var="user">
            <tr>
                <td>${user.userName }</td>
                <td>${user.age }</td>
                <td>${user.sex}</td>
                <td>${user.job}</td>
                <td>${user.school}</td>
                <td>${user.hobby}</td>

                <td>
                    <a href="<%=basePath%>user/getUser?id=${user.id}">编辑</a>
                    <a href="javascript:del('${user.id }')">删除</a>
                </td>

            </tr>
        </c:forEach>
    </tbody>
</table>

</body>
</html>

